package dashboard;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import top.anka1.ims.OSinfo;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.util.Objects;
/**
 * JavaFX Dashboard Application
 * This application serves as a dashboard for various management systems.
 * It allows users to navigate to different modules such as Zoo, Bank, Restaurant, and Shape.
 * The application also includes an About section with copyright information.
 * @author Anka
 */
public class Dashboard extends Application {
    public Dashboard() throws IOException {}

    public Taskbar taskbar = Taskbar.getTaskbar();
    public ImageIcon imageIcon = new ImageIcon(Objects.requireNonNull(Dashboard.class.getResource("Java_1319x1319.png")));
    public Image image = new Image(Objects.requireNonNull(Dashboard.class.getResourceAsStream("Java_1319x1319.png")));
    public FXMLLoader aboutCopyrightLoader = new FXMLLoader(top.anka1.fxgui.AboutCopyrightController.class.getResource("About_Copyright.fxml"));
    public Parent aboutCopyright = aboutCopyrightLoader.load();
    private OSinfo osInfo = new OSinfo();

    @Override
    public void start(Stage primaryStage) throws IOException {
        FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(Dashboard.class.getResource("dashboard-view.fxml")));
        Parent root = loader.load();
        DashBoardController controller = loader.getController();
        Scene scene = new Scene(root);
        primaryStage.setTitle("Dashboard");
        if (osInfo.isMacOS() | osInfo.isMacOSX()) {
            taskbar.setIconImage(imageIcon.getImage());
        }
        primaryStage.getIcons().add(image);
        primaryStage.setScene(scene);
        primaryStage.setOnCloseRequest(event -> {
            event.consume();
            controller.endProgram();
        });
        controller.aboutPane.getChildren().add(aboutCopyright);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
